Ccay.Module.define("Ccay.example.functionDemo.dimensionManage",function(page,$S){
	/**
	 * Grid初始化
	 */
	page.ready=function(){
		$("#dimensionManageDemo").ccayTab();
		var gridOptions={
			editPermission:"Service$Dimension$update",
			columns:[
			 {id: '' ,isCheckColumn : true,frozen:true,align:"center"},
			 {id: 'dimensionCode' ,header:"ccay.security.label.dimensionCode",editable:false,editor:{type:"text",validRule:['R',['MAXL',500],'SPEC']}},
			 {id: 'dimensionName' ,header:"ccay.security.label.dimensionName",editor:{type:"text",validRule:['R',['MAXL',500]]}},
		     {id: 'dimensionField' , header: "ccay.security.label.dimensionField",align:"center", width:60,editor:{type:"text"},hidden:true},
		     {id: 'dimensionType' , header:"ccay.security.label.dimensionType",editor :{ "type" :"select" ,"options" : {"1": $i18n("ccay.security.label.dimensionPerson") ,"0":$i18n("ccay.security.label.dimensionCommon")} },renderer:dimensionTypeRenderer},
		     {id: 'dimensionUrl' , header: "ccay.security.label.dimensionUrl",editor:{type:"textarea",width:"330px",height:"100px",validator:validateUrlContainServerPath},width:323}
			],
			defaultRecord:{dimensionCode:"",dimensionName:"",dimensionField:"",dimensionType:1,dimensionUrl:""},
			operation:{
				search:{
					btn:'#btnSearch',
					panel:'#dimensionCondForm',
					url:'services/ccay/security/dimension/list/page/{0}/{1}'
			},
			save:{
				btn:'#btnSave',
				fn:function(){
					Ccay.UI.showMessage('"'+$(this.btn).attr("value")+'"：为演示Demo！','question');
				}
			},
			add:{
				btn:'#btnAdd'
			}
		}
		
		
	  }
		$S("#dimensionGrid").ccayGrid(gridOptions);
	};
	
	
	function dimensionTypeRenderer(value){
		return (value=="1")?$i18n("ccay.security.label.dimensionPerson") : $i18n("ccay.security.label.dimensionCommon");
	}
	function validateUrlContainServerPath(value) {
		if (!Ccay.DataHelper.isEmpty(value)) {
			if (value.indexOf("servicePath") == -1 || value.indexOf("columnHead") == -1) {
				Ccay.UI.topBox("ccay.security.message.dimensionServerPath" );
				return false;
			} 
			return true;
			
		}
	}

     page.showMsg = function(type){
     	var name = "";
     	if($S(type).attr("value"))
     		name = $S(type).attr("value");
     	else
     		name = $S(type).attr("title");
     	Ccay.UI.showMessage('"'+name+'"：为演示Demo！','question');
     }
});